<?php
namespace app\controllers\api\account;

use fate\http\Request;
use app\models\User;
use app\libs\Util;

class NickexistController extends \fate\web\PureController {
    public function run() {
        $req = Request::getInstance();

        $nick = Util::plainText($req->getParameter('nick'));

        if(!$nick) {
            $this->ajaxReturn(null, 100005);
            exit;
        }

        // 昵称是否已经存在
        $user = new User();
        $has = $user->count("user_name='{$nick}'") > 0;
        if($has) {
            $this->ajaxReturn(null, 100005);
            exit;
        }

        $this->ajaxReturn(null);
    }
}
